<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title><th:block th:text="${edit_game != null} ? '游戏修改' : '游戏添加'"></th:block></title>

    <!-- Bootstrap core CSS -->
    <link th:href="@{/webjars/bootstrap/4.3.1/css/bootstrap.css}" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link th:href="@{/asserts/css/dashboard.css}" rel="stylesheet">
    <!-- 通知栏样式 -->
    <link th:href="@{/asserts/css/notificationBar.css}" rel="stylesheet">
</head>

<body>
<!-- 引入顶部栏 -->
<div th:replace="common/bar::topbar"></div>

<div class="container-fluid">
    <div class="row">
        <!-- 引入通知栏 -->
        <div th:replace="common/bar::NotificationBar"></div>

        <!-- 引入侧边栏 -->
        <div th:replace="common/bar::#sidebar(activeUri='gameman')"></div>

        <!-- 配置映射 -->
        <main id="configMapMain" role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4" >
            <h2><th:block th:text="${edit_game != null} ? '游戏配置映射修改' : '游戏配置映射添加'"></th:block> | <a class="btn btn-sm btn-success"
                     onclick="return gameNewConfigAttribute()">增添新字段</a></h2>
            <hr>
            <input type="hidden" name="id" th:if="${edit_game != null}" th:value="${edit_game.id}"> <!-- id -->
            <input type="hidden" name="configMapAttrCount"
                   th:value="${edit_game != null} ? ${edit_game.gameConfigMap.map.size()} : 0"> <!-- 配置映射字段数量 -->
            <div class="form-group">
                <label>游戏名称</label>
                <input name="name" type="text" class="form-control" placeholder="游戏名称，唯一不可重复。"
                       th:value="${edit_game != null} ? ${edit_game.name}">
            </div>
            <!-- 编辑回显 -->
            <th:block th:if="${edit_game != null}">
                <div class="form-group" th:each="entry : ${edit_game.gameConfigMap.map.entrySet()}">
                    <label th:text="'字段' + ${entryStat.index}"></label>
                    <input th:name="'configMap.key' + ${entryStat.index}" type="text" class="form-control" placeholder="字段索引键，获取和上传时将以这个键为准。"
                           th:value="${entry.key}">
                    <input th:name="'configMap.value' + ${entryStat.index} + '.name'" type="text" class="form-control" placeholder="字段映射名称，将显示在页面上。"
                           th:value="${entry.value.name}">
                    <input type="radio" th:name="'configMap.value' + ${entryStat.index} + '.limitState'" value="false"
                           th:checked="${entry.value.limitState == false} ? checked">无限制
                    <input type="radio" th:name="'configMap.value' + ${entryStat.index} + '.limitState'" value="true"
                           th:checked="${entry.value.limitState == true} ? checked">有限制
                    <input type="text" class="form-control" th:name="'configMap.value' + ${entryStat.index} + '.gameLimit'" placeholder="字段限制值（只有以上设置为有限制才会生效），以Json格式：{&quot;限制值1&quot;：&quot;显示名称1&quot;, &quot;限制值2&quot;：&quot;显示名称2&quot;, ...}，支持中英文符号。"
                        th:value="${entry.value.limit}">
                </div>
            </th:block>

        </main>
        <!-- 数据映射 -->
        <main id="dataMapMain" role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <input type="hidden" name="dataMapAttrCount"
                   th:value="${edit_game != null} ? ${edit_game.gameDataMap.map.size()} : 0"> <!-- 配置映射字段数量 -->
            <h2><th:block th:text="${edit_game != null} ? '游戏数据映射修改' : '游戏数据映射添加'"></th:block> | <a class="btn btn-sm btn-success"
                    onclick="return gameNewDataAttribute()">增添新字段</a></h2>
            <hr>
            <!-- 编辑回显 -->
            <th:block th:if="${edit_game != null}">
                <div class="form-group" th:each="entry : ${edit_game.gameDataMap.map.entrySet()}">
                    <label th:text="'字段' + ${entryStat.index}"></label>
                    <input th:name="'dataMap.key' + ${entryStat.index}" type="text" class="form-control" placeholder="字段索引键，获取和上传时将以这个键为准。"
                           th:value="${entry.key}">
                    <input th:name="'dataMap.value' + ${entryStat.index} + '.name'" type="text" class="form-control" placeholder="字段映射名称，将显示在页面上。"
                           th:value="${entry.value.name}">
                    <input type="radio" th:name="'dataMap.value' + ${entryStat.index} + '.limitState'" value="false"
                           th:checked="${entry.value.limitState == false} ? checked">无限制
                    <input type="radio" th:name="'dataMap.value' + ${entryStat.index} + '.limitState'" value="true"
                           th:checked="${entry.value.limitState == true} ? checked">有限制
                    <input type="text" class="form-control" th:name="'dataMap.value' + ${entryStat.index} + '.gameLimit'" placeholder="字段限制值（只有以上设置为有限制才会生效），以Json格式：{&quot;限制值1&quot;：&quot;显示名称1&quot;, &quot;限制值2&quot;：&quot;显示名称2&quot;, ...}"
                           th:value="${entry.value.limit}">
                </div>
            </th:block>


        </main>

        <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
            <button type="submit" class="btn btn-primary" onclick="return gameSaveOrUpdate()"
                    th:text="${edit_game != null} ? '更新' : '添加'"></button>
        </main>
        <br>
        <br>
        <br>
    </div>
</div>

<!-- 引入公共的js  -->
<div th:replace="common/js::js"></div>
<!-- 自定义的js -->
<script type="text/javascript" th:src="@{/asserts/js/game.js}" ></script>

</body>
</html>